﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MyClassLibrary;
using MyDB;

namespace MyProgram
{
    public partial class FrmExamOverAdd : FrmBaseModify
    {
        public FrmExamOverAdd()
        {
            InitializeComponent();
        }

        MedicareDataClassesDataContext db = new MedicareDataClassesDataContext();

        private void FrmExamOverAdd_Load(object sender, EventArgs e)
        {
            var q = from f in db.ExamCategories
                    select f.檢驗類別名稱;

            this.comboBox2.DataSource = q.ToList();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ExamOverview div = new ExamOverview
            {
                項目_英文名稱_ = this.textBox1.Text,
                中文名稱 = this.textBox2.Text,
                性別 = this.comboBox1.SelectedText,
                單位 = this.textBox4.Text,
                檢驗正常值_上限_ = this.textBox5.Text,
                檢驗正常值_下限_ = this.textBox6.Text,
                危險百分比 = decimal.Parse(this.textBox7.Text),
                檢驗類別ID = this.comboBox2.SelectedIndex + 1
            };

            db.ExamOverview.InsertOnSubmit(div);
            db.SubmitChanges();

            this.Close();
        }
    }
}
